package com.car.crawler;

public class YiChe extends BaseClass {

	@Override
	public void threadRun() {
		for (int i = 0; i < this.getThreadCount(); i++) {
			new Thread(new Runnable() {
				public void run() {
					while (true) {
						String url = getUrl();
						if (url != null) {
							switch(urlType.get(url)){
//							case 0:getHome(url);
//							break;
//							case 1:getAllId(url);
//							break;
//							case 2:getIwomUrl(url);
//							break;
//							case 3:getBbsUrl(url);
//							break;
//							case 4:getIwom(url);
//							break;
							}
						} else {
							threadWait();
						}
					}
				}
			}, "thread-" + i).start();
		}

	}

	@Override
	public void start() {
		this.addOneUrl("http://k.autohome.com.cn/2147/index_1.html", 4);
		logger.info("start---------------------------------------------");
		this.threadRun();

		while (true) {
			if (this.notCrawlurlSet.isEmpty() && Thread.activeCount() == 1
					|| this.waitThreadCount == this.threadCount) {
				System.exit(1);
			}

		}

	}

}
